package com.leyou.item.client;

import com.leyou.common.dto.*;
import com.leyou.common.vo.PageResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient("item-service")
public interface ItemClient {

    @GetMapping("/spu/page")
    public PageResult<SpuDTO> spuPageQuery(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                           @RequestParam(value = "rows", defaultValue = "5") Integer rows,
                                           @RequestParam(value = "key", required = false) String key,
                                           @RequestParam(value = "saleable", required = false) Boolean saleable);

    @GetMapping("/sku/of/spu")
    public List<SkuDTO> findSkusBySpuId(@RequestParam("id") Long id);

    @GetMapping("/spu/detail")
    public SpuDetailDTO findSpuDetailBySpuId(@RequestParam("id") Long id);

    @GetMapping("/spec/params")
    public List<SpecParamDTO> findParams(@RequestParam(value = "gid", required = false) Long gid,
                                         @RequestParam(value = "cid", required = false) Long cid,
                                         @RequestParam(value = "searching", required = false) Boolean searching);

    @GetMapping("/brand/list")
    public List<BrandDTO> findBrandsByIds(@RequestParam("ids") List<Long> ids);

    @GetMapping("/category/list")
    public List<CategoryDTO> findByIds(@RequestParam("ids") List<Long> ids);

    @GetMapping("/spu/{id}")
    public SpuDTO findSpuBySpuId(@PathVariable("id") Long id);

    @GetMapping("/brand/{id}")
    public BrandDTO findById(@PathVariable("id") Long id);

    @GetMapping("/spec/of/category")
    public List<SpecGroupDTO> findGroupByCidWithParams(@RequestParam("id") Long id);

    @GetMapping("/sku/list")
    public List<SkuDTO> findSkusBySkuIds(@RequestParam("ids") List<Long> ids);

    @PutMapping("/stock/minus")
    public Void minusStock(@RequestBody Map<Long, Integer> cartMap);


}
